import Rx from "rxjs"

let foo = Rx.Observable.create(observer => {
    observer.next(6);
})

foo.simulatorMap = function (fn) {
    //外层没有subscribe，里层的subscribe也不会被调用，层层倒退，使得最初的那个observable不会被调用
    return Rx.Observable.create(observer => {
        this.subscribe({
            next: value => {
                console.log("simulator map:"+value); 
                observer.next(fn(value))
            }
        })
    });
}

foo.simulatorMap(x=>x*2).subscribe(function (value) {
    console.log(value);
})